<?php
Zend::loadClass('Lead_EDO_Datatype_Field');

/**
 * Datatype for boolean
 * 
 * @package EDO
 * @subpackage Datatypes
 *
 */
class Lead_EDO_Datatype_Boolean extends Lead_EDO_Datatype_Field
{
	protected $_SQLValueIsQuoted = false;

	function validate($validate)
	{
		if(is_array($validate))
		{
			if(sizeof($validate) == 1 AND !$validate[0])
				$validate = false;
			else 
				$validate = true;
		}
		else 
		{		
			if($validate === 'true')
				$validate = true;
				
			if($validate === 'false')
				$validate = false;
				
		}
						
		if($validate !== true AND $validate !== false)
			return null;
		
		return ($validate === true) ? true : false;
		
	}
		
	
	public function setValue($value)
	{
		$value = $this->validate($value);
		if($value !== null)
		{
			$this->value = $value;
		}
		
		return (is_null($value)) ? false : true;
			
	}
	
	
	public function forceValue($value)
	{
		$this->setValue($value);
	}
	
	
	public function getValue()
	{
			
		return $this->value;
	}
	
	
	public function getValueForSQL()
	{
		return ($this->value === true) ? 'true' : 'false';
	}
	


	
}